//
//  V2LoginViewController.m
//  V2EX
//
//  Created by 花菜ChrisCai on 2016/6/11.
//  Copyright © 2016年 Chris. All rights reserved.
//

#import "V2LoginViewController.h"

@interface V2LoginViewController ()<UITextFieldDelegate>
/** 用户名 */
@property (weak, nonatomic) IBOutlet UITextField *usernameField;
/** 密码 */
@property (weak, nonatomic) IBOutlet UITextField *passwordField;
/** 取消按钮 */
@property (weak, nonatomic) IBOutlet UIButton *closeButton;
/** 登录按钮 */
@property (weak, nonatomic) IBOutlet UIButton *loginButton;
@end

@implementation V2LoginViewController

+ (instancetype)sharedLoginManager
{
    static id _instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [[self alloc]init];
    });
    return _instance;
}
//+ (id)allocWithZone:(NSZone *)zone
//{
//#pragma unused(zone)
//    [NSException raise:NSInvalidArgumentException format:@"*** - [%@ %@]: The %@ class is private to V2LoginViewController and should not be used in this fashion.", NSStringFromClass([self class]), NSStringFromSelector(_cmd), NSStringFromClass([self class])];
//    return(NULL);
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.usernameField addTarget:self action:@selector(valueChange:) forControlEvents:UIControlEventEditingChanged];
    [self.passwordField addTarget:self action:@selector(valueChange:) forControlEvents:UIControlEventEditingChanged];
    [self.usernameField becomeFirstResponder];

}
- (IBAction)beginLongin:(id)sender
{
    self.usernameField.enabled = NO;
    self.passwordField.enabled = NO;
}

- (void)valueChange:(UITextField *)textField
{
   self.loginButton.enabled = (self.usernameField.text.length && self.passwordField.text.length);
}



- (IBAction)dismiss:(UIButton *)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end
